package cn.woniu.clh.controller;

import cn.woniu.clh.entity.Users;
import cn.woniu.clh.service.UserService;
import cn.woniu.clh.util.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/users")
@Api(value = "用户接口1", tags = {"用户接口2"}) //定义接口的组名
public class UserController {

    @Autowired(required = false)
    private UserService userService;

    @ApiOperation("根据姓名查询") //定义接口的名称
    @RequestMapping("queryAllUserByName")
    public ResponseResult<?> queryAllUserByName(String userName){
        return userService.queryAllUserByName(userName);
    }


    @ApiOperation("根据id删除")
    @RequestMapping("deleteUserById")
    public ResponseResult<?> deleteUserById(Integer id){
        return userService.deleteUserById(id);
    }

    @ApiOperation("修改权限")
    @PostMapping("updateUserAuth")
    public ResponseResult<?> updateUserAuth(@RequestBody Users users){
        return userService.updateUserAuth(users);
    }

    @ApiOperation("查询职务")
    @RequestMapping("queryAllJob")
    public ResponseResult<?> queryAllJob(){
        return userService.queryAllJob();
    }

    @ApiOperation("新增用户")
    @PostMapping("addUsers")
    public ResponseResult<?> addUsers(@RequestBody Users users){
        return userService.addUsers(users);
    }

    @ApiOperation("根据用户账号查询用户职务")
    @RequestMapping("queryJobIdByAccount")
    public ResponseResult<?> queryJobIdByAccount(String account){
        return userService.queryJobIdByAccount(account);
    }

    @ApiOperation("根据用户账号查询用户个人信息")
    @RequestMapping("queryUserByAccountMy")
    public ResponseResult<?> queryUserByAccountMy(String account){
        return userService.queryUserByAccountMy(account);
    }

    @ApiOperation("根据用户账号修改用户个人信息")
    @PostMapping("updateUserByAccountMy")
    public ResponseResult<?> updateUserByAccountMy(@RequestBody Users users){
        return userService.updateUserByAccountMy(users);
    }

    @ApiOperation("根据id查询用户账号")
    @RequestMapping("selectIdByAccount")
    public ResponseResult<?> selectIdByAccount(String account){
        return userService.selectIdByAccount(account);
    }
}
